<div id="slide-menu" class="">
	<div id="slide-menu-shadow"></div>
	<div id="slide-menu-content">
		<section>
		  <ul class="list-group"><!--item1 start-->
		  	<li class="list-group-item"><a href="{{Router::url('/wx_promotions/lists/'.$wx_id)}}">{{__('Promotion')}}</a></li>
		  	<li class="list-group-item"><a href="{{Router::url('/wx_storefronts/lists/'.$wx_id.'/1')}}">{{__('Hotel')}}</a></li>
		    <li class="list-group-item"><a href="{{Router::url('/wx_storefronts/lists/'.$wx_id.'/2')}}">{{__('Dining')}}</a></li>
		    <li class="list-group-item"><a href="{{Router::url('/wx_storefronts/lists/'.$wx_id.'/3')}}">{{__('SPA')}}</a></li>
		    <li class="list-group-item"><a href="{{Router::url('/wx_cities/index/2')}}">{{__('Cities')}}</a></li>
		    
		    
		    {{if defined('APPEND_LOCALE_BASE')}}
          		<li class="list-group-item"><a id="eng-link" class="noajax" href="{{$this->Html->image(SUB_DIR.$current_url,array('onlyurl'=>true))}}">English</a></li>
          		<li class="list-group-item"><a id="chi-link" class="noajax" href="{{$this->Html->image(SUB_DIR.'/zh-cn'.$current_url,array('onlyurl'=>true))}}">简体中文</a></li>
          		<li class="list-group-item"><a  id="zhtw-link" class="noajax" href="{{$this->Html->image(SUB_DIR.'/zh-tw'.$current_url,array('onlyurl'=>true))}}">繁體中文</a></li>
          	{{else}}
          		<li class="list-group-item"><a id="eng-link" class="noajax" href="{{$current_url}}">English</a></li>
				<li class="list-group-item"><a id="chi-link" class="noajax" href="{{$this->Html->image(SUB_DIR.'/zh-cn'.$current_url,array('onlyurl'=>true))}}">简体中文</a></li>
				<li class="list-group-item"><a id="zhtw-link" class="noajax" href="{{$this->Html->image(SUB_DIR.'/zh-tw'.$current_url,array('onlyurl'=>true))}}">繁體中文</a></li>
			{{/if}}
			
		    <!-- 
		    {{if defined('APPEND_LOCALE_BASE')}}
          		<li class="list-group-item"><a href="{{$this->Html->image(SUB_DIR.$current_url,array('onlyurl'=>true))}}">English</a></li>
          		<li  class="list-group-item"><a href="{{$this->Html->image(SUB_DIR.'/zh-cn/'.$current_url,array('onlyurl'=>true))}}">简体中文</a></li>
          		<li class="list-group-item"><a href="{{$this->Html->image(SUB_DIR.'/zh-tw/'.$current_url,array('onlyurl'=>true))}}">繁體中文</a></li>
          	{{else}}
          		<li  class="list-group-item"><a href="javascript:;">English</a></li>
				<li class="list-group-item"><a href="{{$this->Html->image(SUB_DIR.'/zh-cn/'.$current_url,array('onlyurl'=>true))}}">简体中文</a></li>
				<li class="list-group-item"><a href="{{$this->Html->image(SUB_DIR.'/zh-tw/'.$current_url,array('onlyurl'=>true))}}">繁體中文</a></li>
			{{/if}}
			 -->
			
		  </ul><!--item1 end-->
		</section>
	</div>
</div>

<!-- helper中追加的底部脚本 $this->_View->append('bottomscript',$script);-->
{{$this->fetch('bottomscript')}}

{{$this->Html->script(array(
          'jquery/jquery.lazyload.js','jquery/jquery.history.js',	
    ));
}}
<script type="text/javascript">
	$(document).ready(function() {
		var last_url = null;
		
		//establish history variables
		var	History = window.History, // Note: We are using a capital H instead of a lower h
			State = History.getState();
		
		//bind to State Change
		History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
			var State = History.getState(); // Note: We are using History.getState() instead of event.state
			
			$('body').css('overflowY','hidden');
			$('#maincontent').append('<div id="loading"><div id="loading-text"><img src="{{$this->Html->image('/img/ajax/circle_ball.gif',array('onlyurl'=>true))}}"> &nbsp; Loading...</div></div>');
			
			if(last_url == State.url){				
				return false;//防止重复加载同一内容
			}
			last_url = State.url;
			$.ajax({
				url:State.url,
				cache:true,
				success:function(msg){
					$('#loading').remove();						
					hideMenu();
					$('body').css('overflowY','auto').scrollTop(0);
					$('#maincontent').html(msg);
					$('#maincontent').fadeIn();
					document.title = $('#pageTitle').html();
					
					$('#eng-link').attr('href',$('#current-url').attr('href'));
					$('#chi-link').attr('href','/zh-cn'+$('#current-url').attr('href'));
					$('#zhtw-link').attr('href','/zh-tw'+$('#current-url').attr('href'));
					
					$("img.lazy").lazyload({placeholder : "{{$this->Html->image('/img/grey.gif',array('onlyurl'=>true))}}",data_attribute  : "src",effect: "fadeIn",threshold : 200});
				}
			});
		});
		
		$(document).on('click','a',function(e){
			
			if(this.href.match(/#/) || $(this).hasClass('noajax') || this.href.indexOf('javascript')>=0 || typeof($(this).attr('onclick'))!='undefined' || (typeof($(this).attr('target'))!='undefined' && $(this).attr('target')!='_self')){ 
				return true;
			}
			
			e.preventDefault();
			e.stopPropagation();
			//$(document).scrollTop(0);
			/*setTimeout(function(){
				$('#loading').remove();
			},2000);*/
			History.pushState(null, null, $(this).attr('href'));
			return false;
		})
		
		
		
		
		$('#slide-menu,#slide-menu-shadow,#slide-menu-content').height($(document).height());
		$('#slide-menu').css('left',-$(window).width());
		$(document).on('click','#toggle-slide-menu',function(){
			showMenu();
		});
		$('#slide-menu-shadow').click(function(){
			hideMenu();
		});
		
		$("img.lazy").lazyload({placeholder : "{{$this->Html->image('/img/grey.gif',array('onlyurl'=>true))}}",data_attribute  : "src",effect: "fadeIn",threshold : 200});
	});
	var scrolltop = 0;
	var menu_show = false;
	function showMenu(){
		menu_show = true;
		scrolltop = $(document).scrollTop();			
		$('#slide-menu,#slide-menu-shadow,#slide-menu-content').height($(document).height());
		$('#slide-menu,#slide-menu-shadow,#slide-menu-content').css('left',-$(window).width());
		$(document).scrollTop(0);
		$('#slide-menu-shadow,#slide-menu,#slide-menu-content').animate({left: '0px'}, 100);
	}
	function hideMenu(){
		menu_show = false;
		$(document).scrollTop(scrolltop);
		$('#slide-menu,#slide-menu-shadow,#slide-menu-content').animate({left: -$(window).width()}, 200); //-$(window).width()
	}

	(function(a){
	    a.fn.touchwipe=function(c){
	        var b={
	            drag:false,
	            min_move_x:20,
	            min_move_y:20,
	            wipeLeft:function(){/*向左滑动*/},
	            wipeRight:function(){/*向右滑动*/},
	            wipeUp:function(){/*向上滑动*/},
	            wipeDown:function(){/*向下滑动*/},
	            wipe:function(){/*点击*/},
	            wipehold:function(){/*触摸保持*/},
	            wipeDrag:function(x,y){/*拖动*/},
	            preventDefaultEvents:true
	        };
	        if(c){a.extend(b,c)};
	        
	        this.each(function(){
	            var h,g,j=false,i=false,e;
	            var supportTouch = "ontouchstart" in document.documentElement;
	            var moveEvent = supportTouch ? "touchmove" : "mousemove",
	            startEvent = supportTouch ? "touchstart" : "mousedown",
	            endEvent = supportTouch ? "touchend" : "mouseup"
	             
	             
	            /* 移除 touchmove 监听 */
	            function m(){
	                this.removeEventListener(moveEvent,d);
	                h=null;
	                j=false;
	                clearTimeout(e)
	            };
	             
	            /* 事件处理方法 */
	            function d(q){
	                
	                if(j){
	                    var n = supportTouch ? q.touches[0].pageX : q.pageX;
	                    var r = supportTouch ? q.touches[0].pageY : q.pageY;
	                    var p = h-n;
	                    var o = g-r;
	                    if(b.drag){
	                        h = n;
	                        g = r;
	                        clearTimeout(e);
	                        b.wipeDrag(p,o);
	                    }
	                    else{
	                        if(Math.abs(p)>=b.min_move_x){
	                        	if(b.preventDefaultEvents){
	        	                    q.preventDefault(); // 仅左右滑动时，阻止浏览器默认事件
	        	                };
	                            m();
	                            if(p>0){
	                            	b.wipeLeft()
	                            }
	                            else{
	                            	b.wipeRight()
	                            }
	                        }
	                        else{
	                            if(Math.abs(o)>=b.min_move_y){
	                                m();
	                                if(o>0){b.wipeUp()}
	                                else{b.wipeDown()}
	                            }
	                        }
	                    }
	                }
	            };
	             
	            /*wipe 处理方法*/
	            function k(){clearTimeout(e);if(!i&&j){b.wipe()};i=false;j=false;};
	            /*wipehold 处理方法*/
	            function l(){i=true;b.wipehold()};
	             
	            function f(n){
	                //if(n.touches.length==1){
	                    h = supportTouch ? n.touches[0].pageX : n.pageX;
	                    g = supportTouch ? n.touches[0].pageY : n.pageY;
	                    j=true;
	                    this.addEventListener(moveEvent,d,false);
	                    e=setTimeout(l,750)
	                //}
	            };
	             
	            //if("ontouchstart"in document.documentElement){
	                this.addEventListener(startEvent,f,false);
	                this.addEventListener(endEvent,k,false)
	            //}
	        });
	        return this
	    };
	})(jQuery);
	 
	/*
	     调用
	
	$(document).touchwipe({
	            wipeLeft:function(){
	            	if(menu_show){
	            		hideMenu();
	            	}
	            	//alert("向左滑动了")
	            },
	            wipeRight:function(){
	            	if(!menu_show){
	            		showMenu();
	            	}
	            	//alert("向右滑动了")
	            },
	})*/
</script>
</body>
</html>
